<?php
    //
    //  Created by Chagan Anton on 29.07.12.
    //  Copyright Chagan Anton 2012. All rights reserved.
    //
/**
 * This is the model class for table "android".
 *
 * The followings are the available columns in table 'android':
 * @property integer $id
 * @property string $subject
 * @property string $content
 * @property string $action
 * @property string $notification_URl
 * @property string $notification_link_label
 * @property string $action_intent
 * @property string $action_categories
 * @property string $action_data
 * @property integer $show_notification_screen
 * @property integer $collect_polling_data
 */
class Android extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Android the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'android';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			//array('id, subject, content, action, notification_URl, notification_link_label, action_intent, action_categories, action_data, show_notification_screen, collect_polling_data', 'required'),
			array('id, show_notification_screen, collect_polling_data', 'numerical', 'integerOnly'=>true),
			array('subject, notification_link_label', 'length', 'max'=>18),
			array('action', 'length', 'max'=>1),
			array('notification_URl, action_data', 'length', 'max'=>24),
			array('action_intent, action_categories', 'length', 'max'=>12),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, subject, content, action, notification_URl, notification_link_label, action_intent, action_categories, action_data, show_notification_screen, collect_polling_data', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		//'msg'=>array(self::HAS_ONE, 'Msg', 'android')
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'subject' => 'Subject',
			'content' => 'Content',
			'action' => 'Action',
			'notification_URl' => 'Notification Url',
			'notification_link_label' => 'Notification Link Label',
			'action_intent' => 'Action Intent',
			'action_categories' => 'Action Categories',
			'action_data' => 'Action Data',
			'show_notification_screen' => 'Show Notification Screen',
			'collect_polling_data' => 'Collect Polling Data',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('subject',$this->subject,true);
		$criteria->compare('content',$this->content,true);
		$criteria->compare('action',$this->action,true);
		$criteria->compare('notification_URl',$this->notification_URl,true);
		$criteria->compare('notification_link_label',$this->notification_link_label,true);
		$criteria->compare('action_intent',$this->action_intent,true);
		$criteria->compare('action_categories',$this->action_categories,true);
		$criteria->compare('action_data',$this->action_data,true);
		$criteria->compare('show_notification_screen',$this->show_notification_screen);
		$criteria->compare('collect_polling_data',$this->collect_polling_data);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}